<?php


header( "Content-type: image/png" );
session_start( );
$code = rand( 100000, 999999 )."";
$GLOBALS['_SESSION']['ses_authCode'] = $code;
if ( !( $im = @imagecreate( 130, 40 ) ) )
{
	exit( "Cannot Initialize new GD image stream." );
}
$background_color = imagecolorallocate( $im, 240, 240, 240 );
$i = 0;
for ( ;	$i <= 128;	++$i	)
{
	$point_color = imagecolorallocate( $im, rand( 0, 255 ), rand( 0, 255 ), rand( 0, 255 ) );
	imagesetpixel( $im, rand( 2, 128 ), rand( 2, 38 ), $point_color );
}
$i = 0;
for ( ;	$i <= 5;	++$i	)
{
	$text_color = imagecolorallocate( $im, rand( 0, 255 ), rand( 0, 128 ), rand( 0, 255 ) );
	$x = 10 + $i * 20;
	$y = rand( 5, 20 );
	imagechar( $im, 5, $x, $y, $_SESSION['ses_authCode'][$i], $text_color );
}
imagepng( $im );
imagedestroy( $im );
?>
